import os,sys
"""
@aurhor niann
获取配置文件中的key
"""
def get_key():
    try: 
        key_conf = open('./conf/easy.conf',"r")
        text = key_conf.read()
        if len(text) == 0:
            raise Exception("./conf/easy.conf is null")
        key = eval(text).get("key")
        if key == None:
            print("NotFound key Please set key: easy config [your key]")
            return
        return key
    except FileNotFoundError:
        open("./conf/easy.conf",'x')
        print("NotFound easy.conf")

'''
@author 
TODO 设置key
'''
def set_key(key):
    if not os.path.exists("./conf"):
        os.makedirs("./conf")
    file = open("./conf/easy.conf","w")
    file.write('''{
        "type":"alibaba",
        "key":"'''+key+'''"\n}''')
    
    print(key)
